Skip to content

Add experimental GitHub telemetry redirection across all SDKs#1835

Merged
MackinnonBuck merged 30 commits into
mainfrom
mackinnonbuck-sdk-github-telemetry-contract
Jul 1, 2026
Merged

Add experimental GitHub telemetry redirection across all SDKs#1835
MackinnonBuck merged 30 commits into
mainfrom
mackinnonbuck-sdk-github-telemetry-contract

Conversation

@MackinnonBuck

Copy link
Copy Markdown
Collaborator

Why

The runtime can now forward per-session GitHub (hydro) telemetry to opted-in host connections via a new JSON-RPC server to client notification, gitHubTelemetry.event. This PR implements the consumer side of that contract in every language SDK so hosts can receive those events. The feature is internal and experimental, so it is intentionally kept low-profile and undocumented for public consumers.

What

For each SDK this adds an onGitHubTelemetry callback (per-language naming) and a hand-written opt-in: when a host registers a handler, the client sets enableGitHubTelemetryRedirection on every session it creates or resumes, and dispatches each gitHubTelemetry.event notification to the callback.

Key pieces:

  • Generated types. Regenerated the RPC types in all languages from the new schema (GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, and the gitHubTelemetry.event clientGlobal method). The shared codegen change adds a notification flag to RpcMethod so generators emit notification-style dispatch (no JSON-RPC reply) for void clientGlobal methods.
  • Hand-written glue. Each SDK surfaces the callback using its existing llmInference / notification idiom and wires the opt-in flag into the create/resume requests. We deliberately reuse the generated RPC types directly rather than introducing friendly wrapper types.
  • Tests. Real-wire tests per language verify the handler fires with a correctly typed payload and that the opt-in flag is present when a handler is registered and omitted otherwise.

Notable decisions

  • One commit per language (plus a small shared codegen-infra commit for utils.ts). This makes the feature trivially revertible language-by-language: reverting a single language's commit removes its support without touching the others. The shared utils.ts change is purely additive (an optional notification? field), so it stays put and never breaks the remaining generators.
  • "Unadvertised" where the language supports it. C# uses [EditorBrowsable(EditorBrowsableState.Never)] and Rust uses #[doc(hidden)]. Languages without a true "exported but hidden" mechanism stay visible + experimental with minimal docs.
  • No public docs. The types are internal/experimental by design.

Review notes

This is the SDK side of a contract whose runtime counterpart is merged-in-progress on the @github/copilot (copilot-agent-runtime) side. The schema is the source of truth; generated files were produced by codegen, not hand-edited.

MackinnonBuck and others added 8 commits June 29, 2026 14:01
Adds an optional
otification marker to the shared RpcMethod interface so
the per-language generators can emit notification-style dispatch (no JSON-RPC
reply) for void clientGlobal methods such as gitHubTelemetry.event.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the TypeScript RPC types for the experimental gitHubTelemetry.event
clientGlobal notification and wires an onGitHubTelemetry callback on the client.
Registering a handler opts created/resumed sessions into telemetry redirection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the C# RPC types for the experimental gitHubTelemetry.event
clientGlobal notification and adds an OnGitHubTelemetry callback. Registering a
handler opts created/resumed sessions into telemetry redirection. The option is
marked [Experimental] and [EditorBrowsable(Never)] to keep it unadvertised.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the Python RPC types for the experimental gitHubTelemetry.event
clientGlobal notification and adds an on_github_telemetry callback. Registering a
handler opts created/resumed sessions into telemetry redirection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the Go RPC types for the experimental gitHubTelemetry.event
clientGlobal notification and adds an OnGitHubTelemetry callback. Registering a
handler opts created/resumed sessions into telemetry redirection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerates the Rust RPC types for the experimental gitHubTelemetry.event
clientGlobal notification and adds an on_github_telemetry callback. Registering a
handler opts created/resumed sessions into telemetry redirection. The telemetry
module is #[doc(hidden)] to keep it unadvertised.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds the experimental gitHubTelemetry.event notification adapter and an
onGitHubTelemetry client option. Registering a handler opts created/resumed
sessions into telemetry redirection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolves conflicts in two generated files where main's @github/copilot 1.0.66-2
bump added new RPC types (GitHubRepoRef, user settings, mcp headers, push
attachments, etc.) adjacent to this branch's GitHubTelemetry* types:
- go/rpc/zrpc.go: union of both sides' struct declarations.
- python/copilot/generated/rpc.py: union of __all__ exports and reconstruction
  of the RPC.from_dict positional constructor call from the (auto-merged)
  assignment order, verified to match the RPC dataclass field order (795 fields).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread rust/src/router.rs Dismissed
@github-actions

This comment has been minimized.

Comment thread dotnet/test/Unit/GitHubTelemetryTests.cs Fixed
Keep experimental GitHub telemetry schema additions available to codegen until they ship in the packaged Copilot schema, and apply formatter output required by CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

MackinnonBuck and others added 2 commits June 30, 2026 12:24
The runtime renamed the per-session opt-in capability from
"redirection" to "forwarding" (wire field enableGitHubTelemetryForwarding)
and updated the GitHubTelemetry schema description strings. This mirrors
that rename across every SDK plus the codegen schema overlay so the
hand-written opt-in flag matches the runtime contract.

Also folds in two PR review fixes:
- dotnet: document the expected-teardown catch in GitHubTelemetryTests
  DisposeAsync (was an empty catch).
- python: re-export GitHubTelemetryNotification/Event/ClientInfo from
  copilot/__init__.py for parity with the nodejs public surface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…hub-telemetry-contract

# Conflicts:
#	go/client_test.go
@MackinnonBuck MackinnonBuck marked this pull request as ready for review June 30, 2026 19:38
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner June 30, 2026 19:38
Copilot AI review requested due to automatic review settings June 30, 2026 19:38
Comment thread python/test_client.py Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements an experimental cross-SDK surface for receiving per-session GitHub (hydro) telemetry forwarded by the runtime via a new JSON-RPC client-global notification (gitHubTelemetry.event). The PR extends shared codegen to understand notification-style RPC methods and wires opt-in + dispatch behavior across TypeScript/Node, Python, Go, Rust, Java, and .NET, with tests validating forwarding and handler invocation.

Changes:

  • Added schema override + shared codegen support for notification-style client-global methods (RpcMethod.notification) and for injecting additive API schema entries during schema loading.
  • Implemented per-SDK “on GitHub telemetry” callback wiring and session create/resume opt-in (enableGitHubTelemetryForwarding) when a handler is registered.
  • Added/updated unit/integration tests across SDKs to validate handler dispatch and the opt-in flag behavior.
Show a summary per file
File Description
scripts/codegen/utils.ts Loads API schema and applies additive overrides; adds notification?: boolean to RpcMethod.
scripts/codegen/typescript.ts Emits onNotification wiring for notification-style client-global methods.
scripts/codegen/schema-overrides/api-additions.schema.json Adds gitHubTelemetry.event + telemetry types via additive schema override (marked notification + experimental).
scripts/codegen/rust.ts Switches schema loading to shared loadSchemaJson (enabling overrides).
scripts/codegen/python.ts Emits notification-handler wiring for notification-style client-global methods.
scripts/codegen/go.ts Adjusts Go codegen for client-global void/notification methods and emits notification-safe handler signatures.
rust/src/github_telemetry.rs New Rust module re-exporting telemetry types + callback alias (doc-hidden).
rust/src/lib.rs Adds client option + plumbing for telemetry callback; adds test constructor helper.
rust/src/router.rs Routes gitHubTelemetry.event client-global notifications to callback (if set).
rust/src/session.rs Sets enableGitHubTelemetryForwarding on create/resume when callback registered.
rust/src/types.rs Initializes new wire fields to None in config→wire conversion.
rust/src/wire.rs Adds enableGitHubTelemetryForwarding wire field to create/resume request DTOs.
rust/src/generated/api_types.rs Generated telemetry DTOs.
rust/tests/session_test.rs Rust integration tests validating opt-in flag and callback dispatch.
python/copilot/_jsonrpc.py Adds method-specific notification handler registry + dispatch path.
python/copilot/generated/rpc.py Generated telemetry DTOs + client-global notification handler registration for gitHubTelemetry.event.
python/copilot/client.py Adds on_github_telemetry option, opt-in flag wiring, and registers client-global handlers.
python/copilot/init.py Re-exports telemetry DTOs at package level.
python/test_client.py Python unit tests for opt-in flag and notification dispatch path.
nodejs/src/generated/rpc.ts Generated telemetry DTOs + onNotification registration for gitHubTelemetry.event.
nodejs/src/types.ts Exposes telemetry DTOs and adds onGitHubTelemetry option type.
nodejs/src/index.ts Re-exports telemetry DTO types from the public entrypoint.
nodejs/src/client.ts Wires onGitHubTelemetry, registers client-global handlers, and sets session opt-in flag.
nodejs/test/client.test.ts Node tests for opt-in flag behavior and notification dispatch.
go/rpc/zrpc.go Generated Go telemetry DTOs + client-global handler interface + registration.
go/types.go Adds OnGitHubTelemetry client option and wire fields on create/resume DTOs.
go/client.go Sets opt-in flag on create/resume and registers telemetry callback adapter.
go/client_test.go Go tests validating opt-in flag serialization and notification routing to callback.
java/src/main/java/com/github/copilot/GitHubTelemetryAdapter.java Java adapter bridging gitHubTelemetry.event into consumer callback.
java/src/main/java/com/github/copilot/CopilotClient.java Registers telemetry adapter on connect; sets opt-in flag on create/resume when handler set.
java/src/main/java/com/github/copilot/rpc/CopilotClientOptions.java Adds experimental setOnGitHubTelemetry option and clones it.
java/src/main/java/com/github/copilot/rpc/CreateSessionRequest.java Adds enableGitHubTelemetryForwarding field + accessors.
java/src/main/java/com/github/copilot/rpc/ResumeSessionRequest.java Adds enableGitHubTelemetryForwarding field + accessors.
java/src/main/java/com/github/copilot/rpc/GitHubTelemetryClientInfo.java Java telemetry DTO.
java/src/main/java/com/github/copilot/rpc/GitHubTelemetryEvent.java Java telemetry DTO.
java/src/main/java/com/github/copilot/rpc/GitHubTelemetryNotification.java Java telemetry DTO.
java/src/test/java/com/github/copilot/GitHubTelemetryTest.java Java tests verifying adapter dispatch and opt-in flag on create/resume.
dotnet/src/Generated/Rpc.cs Generated telemetry DTOs + client-global handler interface and registration.
dotnet/src/Types.cs Adds hidden experimental OnGitHubTelemetry option to CopilotClientOptions.
dotnet/src/Client.cs Sets opt-in flag when handler present; registers telemetry adapter in client-global handlers.
dotnet/test/Unit/GitHubTelemetryTests.cs .NET unit tests validating opt-in behavior and notification forwarding.

Review details

Files not reviewed (1)
  • go/rpc/zrpc.go: Generated file
  • Files reviewed: 36/41 changed files
  • Comments generated: 6
  • Review effort level: Low

Comment thread nodejs/src/client.ts Outdated
Comment thread nodejs/src/client.ts Outdated
Comment thread nodejs/src/client.ts
Comment thread nodejs/src/types.ts Outdated
Comment thread nodejs/test/client.test.ts Outdated
Comment thread python/copilot/_jsonrpc.py Outdated
MackinnonBuck and others added 3 commits June 30, 2026 12:56
Address PR review feedback on the Node telemetry surface:
- Omit enableGitHubTelemetryForwarding from session.create/resume unless a
  handler is registered, matching Go/Python/Rust/dotnet/Java (which all
  omit the field when off) instead of always sending false.
- Isolate consumer callback failures: await the handler inside try/catch so
  async callbacks or thrown errors cannot leak into the JSON-RPC dispatch
  path (mirrors the panic isolation in the other SDKs).
- Widen onGitHubTelemetry to return void | Promise<void> so consumers can
  supply async callbacks.
- Update the no-handler test to assert the field is absent rather than false.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use asyncio.create_task instead of the legacy asyncio.ensure_future when
  scheduling awaitable notification handlers on the event loop thread.
- Drop the redundant local `import asyncio` in the telemetry transport test
  (asyncio is already imported at module scope), clearing CodeQL
  py/repeated-import.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The DisposeAsync teardown catch swallows expected listener/socket shutdown
exceptions. Observe the caught exception so the block is no longer empty,
clearing CodeQL cs/empty-catch-block.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Brings in the @github/copilot 1.0.66 bump (#1859), which re-ran the code
generators and added new RPC/session types (SessionLimits*, SessionCompletions,
AdaptiveThinkingSupport, etc.).

Conflicts were limited to generated files (dotnet Rpc.cs, python rpc.py).
Resolved by installing 1.0.66 and re-running `scripts/codegen` with the
telemetry schema overlay, so every generated file is a consistent product of
the 1.0.66 schema plus the experimental GitHub telemetry additions rather than
a hand-merged blend. Verified 1.0.66 still does not ship the telemetry types,
so the overlay remains required. Codegen is idempotent (re-running produces no
diff) and the hand-written telemetry glue (including the Node conditional-spread
opt-in) is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

The telemetry types ship natively in @github/copilot 1.0.67, so the
hand-maintained schema overlay that injected GitHubTelemetryNotification,
GitHubTelemetryEvent, GitHubTelemetryClientInfo, and the
gitHubTelemetry.event clientGlobal method is no longer needed. Remove the
api-additions overlay and its application plumbing in utils.ts, and revert
rust.ts to read the schema directly. The generic notification-flag codegen
handling is retained, since the published schema marks gitHubTelemetry.event
as a notification.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI requested a review from stephentoub July 1, 2026 13:38
MackinnonBuck and others added 2 commits July 1, 2026 09:27
The clientGlobal method gitHubTelemetry.event is a JSON-RPC notification (schema notification: true, void result). Restore the codegen notification-flag machinery so TypeScript/Python/Go emit notification registration (onNotification / notification-handler table / nil-result SetRequestHandler) instead of request-style onRequest dispatch, and regenerate the affected bindings. Also restore the Python _jsonrpc notification registry and fix the Go adapter to return only an error.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Send an id-less JSON-RPC notification (not a request) through the real wire in the Node and Python unit tests so a regression back to onRequest dispatch is caught. Add a Node E2E that creates a forwarding-enabled session against a live CLI and asserts a gitHubTelemetry.event notification is delivered to the onGitHubTelemetry handler.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

MackinnonBuck and others added 2 commits July 1, 2026 09:41
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Adds a live-CLI E2E in Go, Python, .NET, Rust, and Java that registers an
onGitHubTelemetry callback, creates a session, and asserts at least one
gitHubTelemetry.event notification is forwarded with a well-typed payload.
This brings the other SDKs to parity with the existing nodejs E2E.

Session creation emits an early session.start hydro event, so no model
round-trip (and no recorded CAPI exchange) is needed; the tests are
snapshot-free.

The Rust change also refactors the E2E harness to run a native
COPILOT_CLI_PATH binary directly (non-.js), leaving the node_modules
index.js path unchanged for CI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by SDK Consistency Review Agent for issue #1835 · sonnet46 1.7M

Comment thread python/copilot/client.py Outdated
Comment thread dotnet/src/Client.cs Outdated
Wrap the user-provided on_github_telemetry / OnGitHubTelemetry callback
invocation in exception handling so a throwing handler cannot propagate
into the JSON-RPC dispatch machinery. Mirrors the existing guards in the
Node, Go, Java, and Rust adapters. Errors are logged (Python module
logger; .NET ILogger, falling back to NullLogger.Instance) rather than
silently swallowed, matching the Java (SEVERE) and Rust (warn) behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Comment thread dotnet/src/Client.cs Fixed
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by SDK Consistency Review Agent for issue #1835 · sonnet46 2.7M

Comment thread java/src/main/java/com/github/copilot/GitHubTelemetryAdapter.java Outdated
A user-supplied onGitHubTelemetry callback throwing is a routine,
recoverable condition, not a serious system failure. Level.WARNING
matches the Java SDK''s own convention (CopilotSession "Error in event
handler") and the .NET (LogWarning) and Rust (warn) adapters.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by SDK Consistency Review Agent for issue #1835 · sonnet46 2.6M

Comment thread python/copilot/client.py Outdated
A user-supplied on_github_telemetry callback throwing is a routine,
recoverable condition, not an error. Use logger.warning(..., exc_info=True)
instead of logger.exception (which logs at ERROR), matching the .NET, Java,
and Rust adapters and client.py''s own convention (exc_info=True elsewhere,
never logger.exception).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Comment thread dotnet/src/Types.cs Outdated
The runtime-forwarded gitHubTelemetry.event callback now returns an
awaitable so consumers can perform async I/O in their telemetry sink,
addressing PR feedback. Signatures:

- nodejs:  (n) => void | Promise<void>
- .NET:    Func<GitHubTelemetryNotification, Task>
- Java:    Function<GitHubTelemetryNotification, CompletableFuture<Void>>
- Python:  Callable[[GitHubTelemetryNotification], None | Awaitable[None]]

Each adapter awaits the result and logs handler failures at WARNING.
Go and Rust are intentionally left synchronous; neither SDK has an
async-callback idiom. Unit and E2E call sites updated accordingly.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

All six SDKs (Node.js, Python, Go, .NET, Java, Rust) are modified in this PR with consistent, feature-parity implementations. Here's a summary of what was verified:

Consistent across all SDKs ✅

Aspect Node.js Python Go .NET Java Rust
Callback option onGitHubTelemetry on_github_telemetry OnGitHubTelemetry OnGitHubTelemetry onGitHubTelemetry / setOnGitHubTelemetry on_github_telemetry
Wire flag on create/resume
Notification dispatch
Types exported GitHubTelemetryNotification, Event, ClientInfo same same (via rpc pkg) same (via Rpc ns) same same
Error isolation in adapter
Unit + E2E tests

Language-idiomatic differences (expected, not issues)

  • Async callbacks: Node.js, Python, .NET, Java support async; Go and Rust use sync-only callbacks — this is the standard idiom in those languages.
  • "Hidden" annotation: .NET uses [EditorBrowsable(EditorBrowsableState.Never)], Rust uses #[doc(hidden)] — other languages lack a true "export-but-hide" mechanism.
  • Error logging: Python, .NET, Java, and Rust log a warning when the handler throws/panics; Node.js and Go silently swallow errors (both consistent with each language's general SDK error-handling conventions).

No inconsistencies found

This is a well-executed cross-language feature — the implementation pattern is clearly applied uniformly across all SDKs. Each SDK correctly:

  1. Stores the callback at client construction
  2. Sets enableGitHubTelemetryForwarding: true in both create and resume session payloads when a handler is registered
  3. Dispatches gitHubTelemetry.event notifications to the handler connection-globally
  4. Isolates user callback errors to avoid crashing the notification router

Generated by SDK Consistency Review Agent for issue #1835 · sonnet46 2.3M ·

Comment thread dotnet/src/Client.cs Dismissed
@MackinnonBuck MackinnonBuck added this pull request to the merge queue Jul 1, 2026
Merged via the queue into main with commit 02f2604 Jul 1, 2026
44 of 45 checks passed
@MackinnonBuck MackinnonBuck deleted the mackinnonbuck-sdk-github-telemetry-contract branch July 1, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants